The following functions can be used to construct monitors. A monitor so constructed has the type p4_monitor_t.
p4_moninit
initializes the monitor pointed to by m and gives it i queues for
processes to wait on while they are blocked (see delay). One queue is
sufficient for most purposes. The queues are numbered beginning with 0.
p4_menter
enter the monitor pointed to by m. By the definition of a monitor,
access is restricted to a single process in the monitor at a time (if
everybody plays by the rules).
p4_mexit
exits the monitor pointed to by m. You are of course assumed to have
previously entered that monitor.
p4_mcontinue
checks to see if there are any processes blocked on the i-th queue of
the monitor m and causes one of them to be released for entry to the
monitor if so. If there are no such processes, the invoking process
simply exits. Note that a process could have been blocked previously
by invoking the procedure p4_mdelay. The queues are numbered
beginning with 0.
p4_mdelay
permits a process to delay itself on the i-th queue of monitor
m if the process wishes to release the monitor, but wants to be
waked up by another process later (via the procedure p4_mcontinue).
The queues are numbered beginning with 0.
Some Useful Monitors, ,Monitor-Building Primitives,Functions for Shared Memory